
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.FeedTaskQuality;
import cn.edu.scau.cmi.hombio.domain.FodderStorage;
import cn.edu.scau.cmi.hombio.domain.FodderTake;
import cn.edu.scau.cmi.hombio.domain.FodderType;
import cn.edu.scau.cmi.hombio.domain.Unit;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class FodderTypeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected FodderTypeService service;

	/**
	 * Instantiates a new FodderTypeServiceTest.
	 *
	 */
	public FodderTypeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Delete an existing FeedTaskQuality entity
	* 
	 */
	@Test
	public void deleteFodderTypeFeedTaskQualities() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTypeFeedTaskQualities 
		Integer foddertype_id = 0;
		Integer related_feedtaskqualities_id = 0;
		FodderType response = null;
		response = service.deleteFodderTypeFeedTaskQualities(foddertype_id, related_feedtaskqualities_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderTypeFeedTaskQualities
	}

	/**
	 * Operation Unit Test
	* Save an existing FodderTake entity
	* 
	 */
	@Test
	public void saveFodderTypeFodderTakes() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTypeFodderTakes 
		Integer id = 0;
		FodderTake related_foddertakes = new cn.edu.scau.cmi.hombio.domain.FodderTake();
		FodderType response = null;
		response = service.saveFodderTypeFodderTakes(id, related_foddertakes);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderTypeFodderTakes
	}

	/**
	 * Operation Unit Test
	* Load an existing FodderType entity
	* 
	 */
	@Test
	public void loadFodderTypes() {
		Set<FodderType> response = null;
		response = service.loadFodderTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: loadFodderTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing FodderStorage entity
	* 
	 */
	@Test
	public void deleteFodderTypeFodderStorages() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTypeFodderStorages 
		Integer foddertype_id_1 = 0;
		Integer related_fodderstorages_id = 0;
		FodderType response = null;
		response = service.deleteFodderTypeFodderStorages(foddertype_id_1, related_fodderstorages_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderTypeFodderStorages
	}

	/**
	 * Operation Unit Test
	* Save an existing Unit entity
	* 
	 */
	@Test
	public void saveFodderTypeUnit() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTypeUnit 
		Integer id_1 = 0;
		Unit related_unit = new cn.edu.scau.cmi.hombio.domain.Unit();
		FodderType response = null;
		response = service.saveFodderTypeUnit(id_1, related_unit);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderTypeUnit
	}

	/**
	 * Operation Unit Test
	* Save an existing FodderType entity
	* 
	 */
	@Test
	public void saveFodderType() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderType 
		FodderType foddertype = new cn.edu.scau.cmi.hombio.domain.FodderType();
		service.saveFodderType(foddertype);
	}

	/**
	 * Operation Unit Test
	* Delete an existing FodderType entity
	* 
	 */
	@Test
	public void deleteFodderType() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderType 
		FodderType foddertype_1 = new cn.edu.scau.cmi.hombio.domain.FodderType();
		service.deleteFodderType(foddertype_1);
	}

	/**
	 * Operation Unit Test
	* Save an existing FeedTaskQuality entity
	* 
	 */
	@Test
	public void saveFodderTypeFeedTaskQualities() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTypeFeedTaskQualities 
		Integer id_2 = 0;
		FeedTaskQuality related_feedtaskqualities = new cn.edu.scau.cmi.hombio.domain.FeedTaskQuality();
		FodderType response = null;
		response = service.saveFodderTypeFeedTaskQualities(id_2, related_feedtaskqualities);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderTypeFeedTaskQualities
	}

	/**
	 * Operation Unit Test
	* Save an existing FodderStorage entity
	* 
	 */
	@Test
	public void saveFodderTypeFodderStorages() {
		// TODO: JUnit - Populate test inputs for operation: saveFodderTypeFodderStorages 
		Integer id_3 = 0;
		FodderStorage related_fodderstorages = new cn.edu.scau.cmi.hombio.domain.FodderStorage();
		FodderType response = null;
		response = service.saveFodderTypeFodderStorages(id_3, related_fodderstorages);
		// TODO: JUnit - Add assertions to test outputs of operation: saveFodderTypeFodderStorages
	}

	/**
	 * Operation Unit Test
	* Delete an existing Unit entity
	* 
	 */
	@Test
	public void deleteFodderTypeUnit() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTypeUnit 
		Integer foddertype_id_2 = 0;
		Integer related_unit_id = 0;
		FodderType response = null;
		response = service.deleteFodderTypeUnit(foddertype_id_2, related_unit_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderTypeUnit
	}

	/**
	 * Operation Unit Test
	* Return a count of all FodderType entity
	* 
	 */
	@Test
	public void countFodderTypes() {
		Integer response = null;
		response = service.countFodderTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: countFodderTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing FodderTake entity
	* 
	 */
	@Test
	public void deleteFodderTypeFodderTakes() {
		// TODO: JUnit - Populate test inputs for operation: deleteFodderTypeFodderTakes 
		Integer foddertype_id_3 = 0;
		Integer related_foddertakes_id = 0;
		FodderType response = null;
		response = service.deleteFodderTypeFodderTakes(foddertype_id_3, related_foddertakes_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteFodderTypeFodderTakes
	}

	/**
	 * Operation Unit Test
	* Return all FodderType entity
	* 
	 */
	@Test
	public void findAllFodderTypes() {
		// TODO: JUnit - Populate test inputs for operation: findAllFodderTypes 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<FodderType> response = null;
		response = service.findAllFodderTypes(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllFodderTypes
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findFodderTypeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findFodderTypeByPrimaryKey 
		Integer id_4 = 0;
		FodderType response = null;
		response = service.findFodderTypeByPrimaryKey(id_4);
		// TODO: JUnit - Add assertions to test outputs of operation: findFodderTypeByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
